import React, { Component } from 'react';
import DrawBox from './drawBox';
import CodeBox from './codeBox';
import './style/deskTop.css';

class DeskTop extends Component {
  constructor(props) {
    super(props);
    this.state = {
      code: ''
    };
  }

  onSave = (code) => {
    const { onSave } = this.props;
    onSave(code);
    this.setState({
      code
    });
  }

  render() {
    const { type, clientX, clientY, readySvg } = this.props;
    const { code } = this.state;
    return (
      <div className="deskTop">
        <DrawBox clientX={clientX} clientY={clientY} readySvg={readySvg} onSave={this.onSave} type={type}/> 
        <CodeBox code={code} type={type} />
      </div>
    );
  }
}


export default DeskTop;

